﻿
//
// Copyright (c) 2024 BPer
//
#ifndef INCLUDE_BPERUTIL_SYS_BPERSRTP_H_
#define INCLUDE_BPERUTIL_SYS_BPERSRTP_H_
#include <bperutil/BPerType.h>
#include <stdint.h>
#include <bperutil/sys/BPerThread.h>
#if BPer_Enable_Dtls
#include <srtp2/srtp.h>
typedef struct{
	 srtp_t recvCtx;
	 srtp_t sendCtx;
	 bPer_thread_mutex_t rtpLock;
	 bPer_thread_mutex_t rtcpLock;
}BPerSRtp;
#ifdef __cplusplus
extern "C"{
#endif
    int32_t bPer_create_srtp(BPerSRtp* srtp,char* recv_key,int precvkeylen, char* send_key,int psendkeylen);
    int32_t bPer_destroy_srtp(BPerSRtp* srtp);
    int32_t bPer_enc_rtp(BPerSRtp* srtp,void* packet, int* nb_cipher);
    int32_t bPer_enc_rtcp(BPerSRtp* srtp,void* packet, int* nb_cipher);
    int32_t bPer_dec_rtp(BPerSRtp* srtp,void* packet, int* nb_plaintext);
    int32_t bPer_dec_rtcp(BPerSRtp* srtp,void* packet, int* nb_plaintext);
#ifdef __cplusplus
}
#endif
#endif
#endif /* INCLUDE_BPERUTIL_SYS_BPERSRTP_H_ */
